import React, { useContext } from 'react';
import contextObj from './context'
// 使用useContext这个hook接收数据

const Child1 = () => {

    const { state, dispatch } = useContext(contextObj)
    // console.log('child1', useContext(contextObj));
    return (
        <div>
            Child1
            <p onClick={() => {
                dispatch({ type: 'editage', payload: 30 })
            }}>{state.userinfo.name}--{state.userinfo.age}</p>
        </div>
    );
}

export default Child1;
